class Solution:
    def maxNumberOfFamilies(self, n: int, reservedSeats: list) -> int:
        family = [
            (0b0111111110, 2),
            (0b0111100000, 1),
            (0b0000011110, 1),
            (0b0001111000, 1),
        ]
        seats = {}
        for i in range(len(reservedSeats)):
            reservedSeat = reservedSeats[i]
            r = reservedSeat[0]-1
            if r not in seats:
                seats[r] = 0
            seats[r] = seats[r] | (1 << 10 - reservedSeat[1])
        res = 0
        for seat in seats.values():
            for mode, count in family:
                m = seat ^ mode
                if m & mode == mode:
                    res += count
                    break
            n -= 1
        res += (n * 2)

        return res
